﻿using System;
using System.Collections.Generic;
using System.Text;

namespace designmodule.behavioralmodule.ChainofResponsibility
{
    public abstract class Handler
    {
        protected Handler _successor;

        public void SetSuccessor(Handler successor)
        {
            _successor = successor;
        }

        public abstract void HandleRequest(int request);
    }

    public class ConcreteHandler1:Handler
    {
        public override void HandleRequest(int request)
        {
            if (request>=0 && request<10)
            {
                throw new NotImplementedException();
            }
            else if (_successor != null)
            {
                _successor.HandleRequest(request);    
            }
            
        }
    }

    public class ConcreteHandler2 : Handler
    {
        public override void HandleRequest(int request)
        {
            if (request >= 10 && request < 20)
            {
                throw new NotImplementedException();
            }
            else if (_successor != null)
            {
                _successor.HandleRequest(request);
            }

        }
    }

    public class ConcreteHandler3 : Handler
    {
        public override void HandleRequest(int request)
        {
            if (request >= 20 && request < 30)
            {
                throw new NotImplementedException();
            }
            else if (_successor != null)
            {
                _successor.HandleRequest(request);
            }

        }
    }

}
